package com.itheima.demo.demo12;

import java.util.ArrayList;
import java.util.function.Predicate;

public class LamaPre2 {
    public static void main(String[] args) {
        String[]Array={"张自强，男","姑奶奶，女","红果仔，植物"};
        ArrayList<String> list = method(Array, (String s) -> {
            if (s.equals("红果仔，植物")) {
                return true;
            } else {
                return false;
            }
        });
        System.out.println(list);
    }

    private static ArrayList<String> method(String[]arr, Predicate<String>s) {
        ArrayList<String>list=new ArrayList<>();
        for (String ss : arr) {
            boolean b = s.test(ss);
            if(b){
                list.add(ss);
            }else {
            }
        }
        return list;


    }
}
